/*
 * CircleSliceTest.cpp
 *
 *  Created on: 09-01-2011
 *      Author: Przemek
 */

#include "geometry/CircleSlice.hpp"
#include "utils/MathUtils.hpp"

#define BOOST_TEST_MODULE CircleSlice test
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_CASE( containsIn90DegreeAngleTest )
{
	const CircleSlice slice = CircleSlice(Vector(0, 0), 5, 0, MathUtils::toRadians(90));

	BOOST_CHECK_EQUAL(slice.contains(Vector(0.1f, 0.0f)), true);
	BOOST_CHECK_EQUAL(slice.contains(Vector(3, 0)), true);
	BOOST_CHECK_EQUAL(slice.contains(Vector(4.8f, 0.0f)), true);
	BOOST_CHECK_EQUAL(slice.contains(Vector(2.5f, 2.4f)), true);
	BOOST_CHECK_EQUAL(slice.contains(Vector(2.5f, -2.4f)), true);
	BOOST_CHECK_EQUAL(slice.contains(Vector(-3, 0)), false);
	BOOST_CHECK_EQUAL(slice.contains(Vector(0, 3)), false);
	BOOST_CHECK_EQUAL(slice.contains(Vector(0, -3)), false);
	BOOST_CHECK_EQUAL(slice.contains(Vector(4, 4)), false);
	BOOST_CHECK_EQUAL(slice.contains(Vector(4, -4)), false);
}

BOOST_AUTO_TEST_CASE( containsIn180DegreeAngleTest )
{
	const CircleSlice slice = CircleSlice(Vector(0, 0), 5, -MathUtils::toRadians(90),
			MathUtils::toRadians(180));

	BOOST_CHECK_EQUAL(slice.contains(Vector(-4.0f, -0.5f)), true);
	BOOST_CHECK_EQUAL(slice.contains(Vector(4.0f, -0.5f)), true);
	BOOST_CHECK_EQUAL(slice.contains(Vector(-3, -3)), true);
	BOOST_CHECK_EQUAL(slice.contains(Vector(3, -3)), true);
	BOOST_CHECK_EQUAL(slice.contains(Vector(-1, -4)), true);
	BOOST_CHECK_EQUAL(slice.contains(Vector(1, -4)), true);

	BOOST_CHECK_EQUAL(slice.contains(Vector(-4.0f, 0.5f)), false);
	BOOST_CHECK_EQUAL(slice.contains(Vector(4.0f, 0.5f)), false);
	BOOST_CHECK_EQUAL(slice.contains(Vector(-3, 3)), false);
	BOOST_CHECK_EQUAL(slice.contains(Vector(3, 3)), false);
	BOOST_CHECK_EQUAL(slice.contains(Vector(-1, 4)), false);
	BOOST_CHECK_EQUAL(slice.contains(Vector(1, 4)), false);
}

BOOST_AUTO_TEST_CASE( containsIn270DegreeAngleTest )
{
	const CircleSlice slice = CircleSlice(Vector(0, 0), 5, -MathUtils::toRadians(90),
			MathUtils::toRadians(270));

	BOOST_CHECK_EQUAL(slice.contains(Vector(-4.0f, -0.5f)), true);
	BOOST_CHECK_EQUAL(slice.contains(Vector(4.0f, -0.5f)), true);
	BOOST_CHECK_EQUAL(slice.contains(Vector(-3, -3)), true);
	BOOST_CHECK_EQUAL(slice.contains(Vector(3, -3)), true);
	BOOST_CHECK_EQUAL(slice.contains(Vector(-1, -4)), true);
	BOOST_CHECK_EQUAL(slice.contains(Vector(1, -4)), true);

	BOOST_CHECK_EQUAL(slice.contains(Vector(-1.0f, -0.8f)), true);
	BOOST_CHECK_EQUAL(slice.contains(Vector(1.0f, -0.8f)), true);

	BOOST_CHECK_EQUAL(slice.contains(Vector(-1.0f, 1.2f)), false);
	BOOST_CHECK_EQUAL(slice.contains(Vector(1.0f, 1.2f)), false);
	BOOST_CHECK_EQUAL(slice.contains(Vector(0.0f, 0.8f)), false);
}
